import requests

headers = {'User-Agent':"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
            "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
           "Accept-Encoding": "gzip, deflate, br",
           "Accept-Language": "zh-CN,zh;q=0.9",
           "Connection": "keep-alive",
           "Host": "mtl.xtpxw.com"
           }

def downloadimg(url):
   # dir=listurl[0].split('/')[-2]
    dir="j:/english/test06/"

    response = requests.get(url, headers=headers, allow_redirects=False)
    imgname = url.split('/')[-1]
    path=dir+imgname

    with open(path, 'wb')as img:
        img.write(response.content)

if __name__ == '__main__':
    downloadimg("https://mtl.xtpxw.com/images/img/18390/2.jpg")